import { defineStore } from 'pinia'
import type { RouterTabRaw, LayoutRouterRaw } from '@/@type'

export default defineStore('app', {
  state: () => {
    const sessionRouterTab = JSON.parse(sessionStorage.getItem('router-tab') || '[]')
    return {
      menu: [] as LayoutRouterRaw[],
      collapse: false,
      multipleTab: false,
      // routerTabList设置默认值在使用多标签功能的时候确保首页path有权限，否则需要去除默认值
      routerTabList: (sessionRouterTab.length ? sessionRouterTab : [
        {
          name: 'index',
          fullPath: '/',
          path: '/',
          meta: { title: '控制台' }
        }
      ]) as Array<RouterTabRaw>,
      currentFullPath: '',
      includeCaches: [] as Array<string>
    }
  }
})
